package com.situ.pattern.observer1;

import java.util.ArrayList;
import java.util.List;

public class Subject {
    //报纸内容
    //protected String content;

    private List<Observer> list = new ArrayList<>();

    public void attach(Observer observer) {
        list.add(observer);
    }

    public void detach(Observer observer) {
        list.remove(observer);
    }

    public void notifyObservers() {
        for (Observer observer : list) {
            observer.update(this);
        }
    }
}
